<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\BaseController;
use Illuminate\Http\Request;
use App\SMS\SendTemplateSMS;
use App\SMS\M3Result;
use App\SMS\CCPRestSDK;
use App\Models\User;
use Illuminate\Support\Facades\Cache;
use Overtrue\EasySms\EasySms;


class FindController extends BaseController
{
        // 发送手机验证码
        public function sendcode(Request $request){

            $phone = $request->phone;
            //code
            $config = config('sms');
            $code = rand(1000,9999);
            $name=auth('api')->user()->name;
            Cache::put('phone_code_'.$phone,$code,now()->addMinute(30));
            $easySms = new EasySms($config);

            $easySms->send($phone, [
                'status_code'  => $code,
                'message' => $config['template'],
                'data' => [
                    'name'=>$name,
                    'code' => $code
                ],
            ]);

        }

    }
